<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>生成报表</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		if('${message}' !=null&&'${message}' !=''){
			$("#messageBox").show();
			top.$.jBox.tip('${message}',"success",{persistent:true,opacity:0});
		}
		
		
		
		$("#searchForm").validate({
				submitHandler: function(form){
				/* 	loading('正在查询，请稍等...'); */
					form.submit();
				},
		
		
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});
		

		
		$("#a_all").click(function(){
			$("#contain_all").show();
			$("#contain_det").hide();
		
			$("#li_all").addClass("active");
			$("#li_det").removeClass("active");
		});
		
		$("#a_det").click(function(){
			$("#contain_all").hide();
			$("#contain_det").show();
		
			$("#li_all").removeClass("active");
			$("#li_det").addClass("active");
		});
		
		
	});
		
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
    	return false;
    }
	
	function changeSelect(val,param,target){
		
		 $.ajax({
				type : 'post',
				url : "${ctx}/report/produce/getSelectList", 
				cache : false,
				context : $(this),
				dataType : 'json',
				data : {
					value: val,
					data: param
				},
				success : function(data) {
				$("select[name="+target+"]").empty();
				$("select[name="+target+"]").get(0).options.add(new Option("请选择",""));
				$.each(data, function (n, temp) {  
					$("select[name="+target+"]").get(0).options.add(new Option(temp.label,temp.value));
		          });  
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#messageBox").html("*系统异常，请重试").css("display","block");
				}
			});
	}
	
	
	function getDetail(index){
		$("#detail_form_"+index).submit();
	}
	</script>
</head>
<body>
<ul class="nav nav-tabs">
		<li class="active" id="li_all"><a id="a_all" href="#">导出详情</a></li>
</ul>
	<!-- <script type="text/javascript">top.$.jBox.closeTip();</script> -->
	<div id="messageBox" class="alert alert-success hide" style="display: none;"><button data-dismiss="alert" class="close">×</button>${message}</div> 
<!-- 	<script type="text/javascript">if(!top.$.jBox.tip.mess){
		alert(top.$.jBox.tip.mess);
		top.$.jBox.tip.mess=1;
		top.$.jBox.tip('${message}',"success",{persistent:true,opacity:0});$("#messageBox").show();}
	</script> -->
<%-- 	<sys:message content="${message}"/> --%>
	<div id="contain_all" >
	<form:form id="searchForm"  action="${ctx}/report/produce/exportFileList?id=${report.id }&fv=${report.fv }" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		
		<table border="0" st>
		<c:forEach items="${report.configIns}" var="reportConfigIn" varStatus="status">
			<c:choose>
				<c:when test="${status.index%4==0 }">
					<tr>
				</c:when>
			</c:choose>
				<td>
					<label>${reportConfigIn.itemName }：</label>
				</td>
				<td>
					<c:if test="${reportConfigIn.itemType eq '0' }">
							<input type="text" name="${reportConfigIn.itemCode }" htmlEscape="false"  class="input-medium" value="${reportConfigIn.paramValue }"/>
					</c:if>
					<c:if test="${reportConfigIn.itemType eq '1' }">
							<input type="text" name="${reportConfigIn.itemCode }" htmlEscape="false"  class="input-medium digits" value="${reportConfigIn.paramValue }"/>
					</c:if>
					<c:if test="${reportConfigIn.itemType eq '2' or reportConfigIn.itemType eq '3' or reportConfigIn.itemType eq '4'  }">
						<c:if test="${reportConfigIn.fn ne '' and reportConfigIn.param ne '' and reportConfigIn.target ne ''}"><select name="${reportConfigIn.itemCode }" class="input-medium" value="${reportConfigIn.paramValue }" onchange="${reportConfigIn.fn }(this.value,'${reportConfigIn.param }','${reportConfigIn.target }')"></c:if>
						<c:if test="${reportConfigIn.fn eq '' or reportConfigIn.param eq '' or  reportConfigIn.target eq ''}"><select name="${reportConfigIn.itemCode }" class="input-medium" value="${reportConfigIn.paramValue }"></c:if>
							<option value="">请选择</option>
							<c:forEach items="${reportConfigIn.selectList}" var="dict">
								<c:choose>
									<c:when test="${reportConfigIn.paramValue eq  dict.value}">
										<option value="${dict.value }" selected="selected">${dict.label }</option>
									</c:when>
									<c:otherwise>
										<option value="${dict.value }">${dict.label }</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</select>
						<c:if test="${reportConfigIn.fn ne '' and reportConfigIn.param ne '' and reportConfigIn.target ne ''}">
						<script type="text/javascript">
						$(document).ready(function() {
							var val=$("select[name=${reportConfigIn.itemCode }]").val();
							changeSelect(val,'${reportConfigIn.param }','${reportConfigIn.target }');
						});
						</script>
						</c:if>
					</c:if>
					<c:if test="${reportConfigIn.itemType eq '5' }">
						<input type="text" id="${reportConfigIn.itemCode }" name="${reportConfigIn.itemCode }" htmlEscape="false" maxlength="32" readonly="readonly" value="${reportConfigIn.paramValue }" class="input-medium Wdate"
					 onclick="WdatePicker({dateFmt:'${reportConfigIn.checkType}',isShowClear:true});"/>	
					</c:if>
				</td>
				<c:if test="${status.index%4==3}">
					</tr>
				</c:if>
				<c:if test="${ status.last}">
					<td>
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
					</td>
					<td>
						<c:if test="${report.isExport eq '1' }">
							<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
						</c:if>
					</td>
					</tr>
				</c:if>
		</c:forEach>
		</table>
	</form:form>
	<table id="reportTable" class="table table-bordered table-condensed" >
		<thead style="background-color:#F5F5F5">
			<tr>
				<th>序号</th>
				<c:forEach items="${report.configOuts}" var="reportConfigOut">
					<c:if test="${reportConfigOut.isDetail ne '0' }">
						<th>${reportConfigOut.itemName }</th>
					</c:if>
				</c:forEach>
				

					<th>操作</th>

			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="map" varStatus="idx">
				<tr>
					<td>${idx.index+1}</td>
					<c:forEach items="${report.configOuts}" var="reportConfigOut">
						<c:if test="${reportConfigOut.isDetail ne '0' }">
							<td>${map[reportConfigOut.itemCode] }</td>
						</c:if>
					</c:forEach>
					<td>
					<c:if test="${map['EX_STATUS'] eq '4' }">
					<a href="#"  onclick="getDetail('${idx.index+1}')">下载文件</a><span id="span_${idx.index+1}" style="display: none;">
					<form action='${ctx}/report/produce/downLoadFile?id=${map["ID"]}&report_id=${report.id}' method='POST' id="detail_form_${idx.index+1}">
           				 
           			</form>
					</span>
					</c:if>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>

	<div class="pagination">${page}</div>
	</div>
	
</body>
</html>